package com.vip.mongofile.service.impl;

import com.vip.common.response.Result;
import com.vip.mongofile.model.MongoFile;
import com.vip.mongofile.service.FileService;
import com.vip.mongofile.constant.FileStorageEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description: 文件存储抽象层
 * @Date: 2020/12/04 16:05
 * @Author: wp
 **/
@Slf4j
public abstract class AbstractFileStorageService implements FileService {

    public final Result<MongoFile> uploadFile(MultipartFile file) {
        Result<MongoFile> result = saveFile(file);
        log.info("文件上传 -> 上传外部存储成功");
        return result;
    }

    public final Result<String> deleteFile(String mongodbId) {
        Result<String> result = removeFile(mongodbId);
        log.info("删除文件 -> 删除外部存储成功");
        return result;
    }

    /**
     * 获取文件存储类型
     * @return
     */
    public abstract FileStorageEnum getEnumType();

}
